package com.oa.modules.approvalsec1.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.oa.modules.approvalsec1.entity.ProcessEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 项目流程表
 *
 * @author yangewenzhi
 * @email 785297226@qq.com
 * @date 2021-12-15 17:37:00
 */
@Mapper
public interface ProcessDao extends BaseMapper<ProcessEntity> {


    /**
     * 查询总条数
     *
     * @author yangewenzhi
     * @email 785297226@qq.com
     * @date 2021-12-15 17:37:00
     * @Description 查询分页数据
     */
    @Select("<script>SELECT COUNT( 1 ) FROM (" +
            "select t1.* from process t1  " +
            "where 1=1 " +
            "<if test = 'params != null'> "+
            "and t1.`STATUS` = #{params.status} " +
            "<if test='params.name != null'>and t1.name LIKE '%${params.name}%'  </if> " +
            ")</if> TOTAL" +
            "</script>")
    long findPage(@Param("params") Map<String, Object> params);

    /**
     * 查询分页数据
     *
     * @author yangewenzhi
     * @email 785297226@qq.com
     * @date 2021-12-15 17:37:00
     * @Description 查询分页数据
     */
    @Select("<script>select t1.* from process t1 " +
            "where 1=1" +
            " and t1.`STATUS` = #{params.status} " +
            "<if test='params.name != null'>and t1.name LIKE '%${params.name}%'  </if> " +
            "ORDER BY t1.CREATE_DATE desc</script>")
    List<ProcessEntity> findRecords(IPage<ProcessEntity> page, @Param("params") Map<String, Object> params);

    void add(ProcessEntity process);
}
